#ifndef __E2PFS_H__
#define __E2PFS_H__

#define E2PFS_MAGIC			0x20210121
#define E2PFS_ROOT_INODE	0
#define E2PFS_BLOCK_SIZE	128
#define E2PFS_BLOCK_NUM		512

#define E2PFS_FILENAME_MAX	16
#define E2PFS_ROOT_INODE_NUMBER	1

enum block_type {
	BLOCK_TYPE_INODE = 0x01,
	BLOCK_TYPE_DIR = 0x10,
	BLOCK_TYPE_DATA = 0x11,
};

enum block_status {
	BLOCK_EMPTY,
	BLOCK_FULL,
};

enum data_block_status {
	DATA_MISSING,
	DATA_COMPLETE,
};

struct e2pfs_inode {
	/* common:
     * bit6 ~ bit7 :
	 *            dir_blk_num bit8 ~ bit9
     * bit4 ~ bit5:
	 *            data_blk_num bit8 ~ bit9
     * bit1 ~ bit3:
	 * 			  reserved
     * bit0 :
	 * 		0: DIR
     *      1: REG
	 */
	uint8_t common;
	uint8_t i_no;
	uint8_t parent_i_no;
	/* dir_blk_num bit0 ~ bit7 */
	uint8_t dir_blk_num;
	/* *data_blk_num bit0 ~ bit7 */
	uint8_t data_blk_num;
	union {
		uint16_t filesize;
		uint16_t child_count;
	};
};

struct e2pfs_directory {
	int8_t filename[E2PFS_FILENAME_MAX];
	/* used for match e2pfs inode */
	uint8_t i_no;
};

struct e2pfs_super_block {
	uint32_t magic;
	uint32_t block_size;
	uint8_t free_blocks[64];
	struct e2pfs_inode root_inode;
};

#endif
